<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <!-- 引入layui 样式-->
    <link rel="stylesheet" href="../../static/layer/css/layui.css"/>
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
    <script type="text/javascript" src="../../static/layer/layui.js"></script>
    <style>
        .datebox{
            width: 100px;
        }
        .jinebox{
            width: 75px;
        }
        .zhangdantype{
            width: 100px;
        }
    </style>
    <style>
        .lay-box{
            width: 1024px;
        }
        .layui-table-fixed.layui-table-fixed-b{
            top: inherit;
            z-index: 2;
        }
        .layui-table-fixed.layui-table-fixed-br{
            top: inherit;
            z-index: 2;
        }
        #tabBox{
            width: 1200px;
        }

        #tabBox .laytable-cell-1-index{
            background: #f5f5f5;
        }
        .layui-table-foot td{
            border-bottom:0
        }
    </style>
</head>
<body>

<div class="layui-tab layui-tab-brief" lay-filter="expense_management">

    <ul class="layui-tab-title">
        <li class="layui-this" data-2tab="0">收费列表</li>
        <li data-2tab="1">流水明细</li>
    </ul>
    <div class="layui-tab-content">
        <!--收租列表-->
        <div class="layui-tab-item layui-show">
            <div class="layui-tab layui-tab-brief" lay-filter="toll_list">
                <ul class="layui-tab-title">
                    <li class="layui-this" data-szlx="1">应收</li>
                    <li data-szlx="2">已收</li>

                </ul>
                <div class="layui-tab-content" style="height: 100px;">
                    <div class="layui-tab-item layui-show">
                        <!--应收 未收租列表-->
                        <div class="operateTablews">
                            <div class="layui-inline">
                                <input class="layui-input" name="COMPANY_NAME" id="COMPANY_NAMEw" placeholder="借款方名称" >
                            </div>
                            <div class="layui-inline">
                                <input class="layui-input" name="BYNAMEw" id="BYNAMEw" placeholder="别名" >
                            </div>
                            <div class="layui-inline datebox" >
                                <input class="layui-input" name="START_DATE" id="START_DATEw" placeholder="开始时间" >
                            </div>
                            <div class="layui-inline datebox" >
                                <input class="layui-input" name="END_DATE" id="END_DATEw" placeholder="结束时间" >
                            </div>
                            <div class="layui-inline datebox">
                                <select name="BILL_JEQJ" id="BILL_JEQJw" class="layui-input qiehuanw">
                                    <option value="">账单金额</option>
                                    <option value="0">固定</option>
                                    <option value="1">区间</option>
                                </select>
                            </div>
                            <div class="qiehuanjinew layui-inline">
                            </div>
                            <button class="layui-btn ws" data-type="reload">搜索</button>
                            <!--<a class="layui-btn layui-btn-normal plsf AUTH-CWQX_SF">批量收费</a>-->
                            <a class="layui-btn layui-btn-normal plsf-ys AUTH-CWQX_DYZD">打印凭证</a>
                            <!--<a class="layui-btn layui-btn-normal AUTH-CWQX_DCZD" onclick="excel();">导出Excel</a>-->
                        </div>
                        <table id="szlb" lay-filter="szlbf"></table>
                        <!--财务权限-->
                        <div style="display: none;" id="dclbar">

                            <a class="layui-btn layui-btn-primary layui-btn-mini AUTH-CWQX_ZDCK" lay-event="detail">查看</a>

                            <a class="layui-btn layui-btn-normal layui-btn-mini AUTH-CWQX_DYZD" lay-event="print">打印</a>

                            <a class="layui-btn layui-btn-mini AUTH-CWQX_SF" lay-event="dclsf">收费</a>

                            <!--<a class="layui-btn layui-btn-primary layui-btn-mini AUTH-CWQX_BJZD" lay-event="editbill">修改</a>-->

                        </div>

                    </div>
                    <div class="layui-tab-item">
                        <!--已收租列表-->
                        <div class="operateTableys">
                            <div class="layui-inline">
                                <input class="layui-input" name="COMPANY_NAME" id="COMPANY_NAME" placeholder="借款方名称" >
                            </div>
                            <div class="layui-inline">
                                <input class="layui-input" name="BYNAME" id="BYNAME" placeholder="别名" >
                            </div>
                            <div class="layui-inline datebox">
                                <input class="layui-input" name="START_DATE" id="START_DATE" placeholder="开始时间" >
                            </div>
                            <div class="layui-inline datebox">
                                <input class="layui-input" name="END_DATE" id="END_DATE" placeholder="结束时间" >
                            </div>
                            <div class="layui-inline datebox">
                                <select name="BILL_JEQJ" id="BILL_JEQJw" class="layui-input qiehuan">
                                    <option value="">账单金额</option>
                                    <option value="0">固定</option>
                                    <option value="1">区间</option>
                                </select>
                            </div>
                            <div class="qiehuanjine layui-inline">
                            </div>
                            <button class="layui-btn ys" data-type="reload">搜索</button>
                            <a class="layui-btn layui-btn-normal AUTH-CWQX_DCZD" onclick="excel_yichuli();">导出Excel</a>
                        </div>
                        <table id="yichuli" lay-filter="yichulif"></table>
                       <!-- <script type="text/html" id="yclbar">-->
                            <div style="display: none;"  id="yclbar">
                            <a class="layui-btn layui-btn-primary layui-btn-mini AUTH-CWQX_ZDCK" lay-event="detail">查看</a>
                            </div>
                       <!-- </script>-->
                    </div>
                </div>
            </div>
        </div>
        <!--流水明细-->
        <div class="layui-tab-item">
            <div class="layui-tab layui-tab-brief" lay-filter="lsmx">
                <ul class="layui-tab-title">
                    <li class="layui-this" data-lsmx="0">收入</li>
                    <li data-lsmx="1">支出</li>
                </ul>
                <div class="layui-tab-content" style="height: 100px;">
                    <div class="layui-tab-item layui-show">
                        <!--收入-->
                        <div class="operateTablesy">
                            <div class="layui-inline">
                                <input class="layui-input" name="COMPANY_NAME" id="COMPANY_NAMEsy" placeholder="借款方名称" >
                            </div>
                            <div class="layui-inline">
                                <input class="layui-input" name="BYNAMy" id="BYNAMsy" placeholder="别名" >
                            </div>
                            <div class="layui-inline datebox">
                                <input class="layui-input" name="START_DATE" id="START_DATEsy" placeholder="开始时间" >
                            </div>
                            <div class="layui-inline datebox">
                                <input class="layui-input" name="END_DATE" id="END_DATEsy" placeholder="结束时间" >
                            </div>
                            <button class="layui-btn" data-type="reload">搜索</button>
                            <a class="layui-btn layui-btn-normal AUTH-CWQX_DCZD" onclick="excel_shouru();">导出Excel</a>
                        </div>
                        <table id="srtable" lay-filter="lsmxf"></table>
                        <!--<script type="text/html" id="lsmxbar">-->
                            <div style="display: none;"  id="lsmxbar">
                            <a class="layui-btn layui-btn-primary layui-btn-mini AUTH-CWQX_ZDCK" lay-event="detail">查看</a>
                            </div>
                      <!--  </script> -->
                    </div>
                    <div class="layui-tab-item">
                        <!--支出-->
                        <div class="operateTablezc">
                            <div class="layui-inline">
                                <input class="layui-input" name="COMPANY_NAME" id="COMPANY_NAMEzc" placeholder="借款方名称" >
                            </div>
                            <div class="layui-inline">
                                <input class="layui-input" name="BYNAME" id="BYNAMEzc" placeholder="别名" >
                            </div>
                            <div class="layui-inline datebox">
                                <input class="layui-input" name="START_DATE" id="START_DATEzc" placeholder="开始时间" >
                            </div>
                            <div class="layui-inline datebox">
                                <input class="layui-input" name="END_DATE" id="END_DATEzc" placeholder="结束时间" >
                            </div>
                            <button class="layui-btn" data-type="reload">搜索</button>
                            <a class="layui-btn layui-btn-normal AUTH-CWQX_DCZD" onclick="excel_zhichu();">导出Excel</a>
                        </div>
                        <table id="zctable" lay-filter="zcf"></table>
                        <div style="display: none;"  id="zcbar">
                            <a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="detail">查看</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="../../static/js/common/queryUtils.js"></script>
<script type="text/javascript" src="../../static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../../static/js/common/authUtils.js"></script>
<!--<script type="text/javascript" src="../../static/ujs/rent/rent.js"></script>-->
<script>
    // 加载元素控件
    var table;
    //获取 选中楼宇id   商圈id
    var $;
    layui.use(['jquery', 'element', 'layer', 'laydate', 'form', 'table'], function () {
        $ = layui.jquery, element = layui.element, layer = layui.layer, form = layui.form, table = layui.table, laydate = layui.laydate;
        //获取当前月
        var loan_price = QueryUtils.GetQueryString("loan_price");
        var date_ = new Date();
        var year = date_.getFullYear();
        var month = date_.getMonth() + 1;
        var paystar = year + '-' + month + '-01'
        var day = new Date(year, month, 0);
        var payend = year + '-' + month + '-' + day.getDate();

        //（1）收租列表
        //加载待处理账单
        var data = {};
        data.paystar = paystar;
        data.payend = payend;
        data.loan_price=loan_price;
        //默认显示时间
        //应收
        $("#START_DATEw").val(paystar);
        $("#END_DATEw").val(payend)

        //已收
        $("#START_DATE").val(paystar);
        $("#END_DATE").val(payend)



        //应付
        $("#START_DATEyf").val(paystar);
        $("#END_DATEyf").val(payend)





        //初始化时间
        laydate.render({
            elem: '#START_DATE'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEw'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEy'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATE'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEw'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEy'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEsy'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEsy'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEzc'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEzc'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEsyys'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEsyys'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEziy'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEziy'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEyf'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEyf'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEtzjs'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEtzjs'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#END_DATEspzd'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#START_DATEspzd'
            , format: 'yyyy-MM-dd'
        });


        var tabselect;
        //收费列表
        element.on('tab(toll_list)', function (data1) {
            //加载已处理账单  已收
            tabselect = $(this).data("szlx");
            switch (tabselect){
                case 2:
                    table.render({
                        elem: '#yichuli'
                        , url: '/LoanController/yishouList'
                        , where: data
                        , cols: [[
                             {field: 'COMPANY_NAME', event: 'setSign', title: '借款方', width: 120, sort: 'true'}
                            , {field: 'BYNAME', event: 'setSign', title: '别名', width: 120, sort: 'true'}
                            , {field: 'TOTAL_PRICE', event: 'setSign', title: '金额', width: 120, align: 'right',sort: 'true'}
                            , {field: 'START_DATE', event: 'setSign', title: '账单周期', width: 200, sort: 'true'}
                            , {field: 'BILL_NAME', event: 'setSign', title: '账单类型', width: 120, sort: 'true'}
                            /*, {field: 'STATE', event: 'setSign', title: '账单状态', width: 120}*/
                            , {field: 'PAY_DATE', event: 'setSign', title: '应收费日', width: 120, sort: 'true'}
                            , {field: 'PAY_PRICE', event: 'setSign', title: '实收金额', width: 120, align: 'right',sort: 'true'}
                            , {field: 'ACT_PAY_DATE', event: 'setSign', title: '实收日期', width: 120, sort: 'true'}
                            , {field: 'ALLOT_BILL', event: 'setSign', title: '收费类型', align: 'center', width: 120, sort: 'true'}
                            , {field: 'IF_COLLECTION', event: 'setSign', title: '自动扣款', align: 'center', width: 120, sort: 'true'}
                            , {field: 'COLLECTION_STATE', event: 'setSign', title: '扣款状态', align: 'center', width: 120, sort: 'true'}
                            , {field: 'MAKE_BILL_TYPE', event: 'setSign', title: '生成类型', align: 'center', width: 120}
                            , {fixed: 'right', width: 160, align: 'center', title: '操作', toolbar: '#yclbar'}

                        ]]
                        , id: 'yclID'
                        , page: true
                        , height: 470
                        , limit: '10'
                        , done: function(res, curr, count){
                            var total=0;
                            for(var i=0;i<res.data.length;i++){
                                total+=parseFloat(res.data[i].PAY_PRICE);
                            }
                            $(".total_price").remove();
                            $(".layui-table-page").append('<span class="total_price" style="height: 10px;margin:10px 10px 0px 30px"><span>账单实收金额汇总：' + total.toFixed(2)+'元</span></span>');

                        }
                    });
                    break;
                case 3:
                    //加载应付 账单
                    break;
                case 4:
                    break;
                case 5:
                    break;


            }
        });
        //流水明细
        element.on('tab(lsmx)', function (data2) {
            //加载已处理账单  已收
            tabselect = $(this).data("lsmx");
            switch (tabselect){
                case 0:
                    //（2）留水明细
                    //加载收入列表
                    table.render({
                        elem: '#srtable'
                        , url: '/LoanController/lsmxshouru'
                        , where: data
                        , cols: [[

                            {field: 'COMPANY_NAME', event: 'setSign', title: '借款方', width: 120, sort: 'true'}
                            , {field: 'BYNAME', event: 'setSign', title: '别名', width: 120, sort: 'true'}
                            , {field: 'PAY_PRICE', event: 'setSign', title: '支付金额', width: 120,align: 'right', sort: 'true'}
                            , {field: 'START_DATE', event: 'setSign', title: '账单周期', width: 200, sort: 'true'}
                            , {field: 'BILL_NAME', event: 'setSign', title: '账单类型', width: 120, sort: 'true'}
                            , {field: 'COLLECTION_TYPE', event: 'setSign', title: '收款账户', width: 120, sort: 'true'}
                            , {field: 'ACT_PAY_DATE', event: 'setSign', title: '实收日期', width: 120, sort: 'true'}
                            , {field: 'PAY_METHOD', event: 'setSign', title: '支付方式', width: 140, sort: 'true'}
                            , {field: 'PAY_TRANSACTION', event: 'setSign', title: '流水号', width: 140, sort: 'true'}
                            , {field: 'INFO', event: 'setSign', title: '备注', width: 120, sort: 'true'}
                            , {fixed: 'right',  event: 'setSign', align: 'center',title: '操作', toolbar: '#lsmxbar', width: 160}

                        ]]
                        , id: 'shouruID'
                        , page: true
                        , height: '470'
                        , limit: '10'
                        , done: function(res, curr, count){
                            var total=0;
                            for(var i=0;i<res.data.length;i++){
                                total+=parseFloat(res.data[i].PAY_PRICE);
                            }
                            $(".total_price").remove();
                            $(".layui-table-page").append('<span class="total_price" style="height: 10px;margin:10px 10px 0px 30px"><span>账单金额汇总：' + total.toFixed(2)+'元</span></span>');
                        }
                    });
                    break;
                case 1:
                    table.render({
                        elem: '#zctable'
                        , url: '/LoanController/lsmxzhichu'
                        , where: data
                        , cols: [[
                             {field: 'COMPANY_NAME', event: 'setSign', title: '借款方', width: 120, sort: 'true'}
                            , {field: 'BYNAME', event: 'setSign', title: '别名', width: 120, sort: 'true'}
                            , {field: 'PAY_PRICE', event: 'setSign', title: '支付金额', width: 120,align: 'right', sort: 'true'}
                            , {field: 'START_DATE', event: 'setSign', title: '账单周期', width: 200, sort: 'true'}
                            , {field: 'BILL_NAME', event: 'setSign', title: '账单类型', width: 120, sort: 'true'}
                            , {field: 'COLLECTION_TYPE', event: 'setSign', title: '收款账户', width: 120, sort: 'true'}
                            , {field: 'ACT_PAY_DATE', event: 'setSign', title: '实收日期', width: 120, sort: 'true'}
                            , {field: 'PAY_METHOD', event: 'setSign', title: '支付方式', width: 140, sort: 'true'}
                            , {field: 'PAY_TRANSACTION', event: 'setSign', title: '流水号', width: 140, sort: 'true'}
                            , {field: 'INFO', event: 'setSign', title: '备注', width: 120, sort: 'true'}
                            , {fixed: 'right',  event: 'setSign', align: 'center',title: '操作', toolbar: '#lsmxbar', width: 160}

                        ]]
                        , id: 'zhichuID'
                        , page: true
                        , height: '470'
                        , limit: '10'
                        , done: function(res, curr, count){
                            var total=0;
                            for(var i=0;i<res.data.length;i++){
                                total+=parseFloat(res.data[i].PAY_PRICE);
                            }
                            $(".total_price").remove();
                            $(".layui-table-page").append('<span class="total_price" style="height: 10px;margin:10px 10px 0px 30px"><span>账单金额汇总：' + total.toFixed(2)+'元</span></span>');
                        }
                    });
                    break;
            }
        });
        //收入预算 退租结算 审批账单
        element.on('tab(expense_management)', function (data1) {
            tabselect = $(this).data("2tab");
            switch (tabselect){
                case 1:
                    //加载流水明细
                    table.render({
                        elem: '#srtable'
                        , url: '/LoanController/lsmxshouru'
                        , where: data
                        , cols: [[
                             {field: 'COMPANY_NAME', event: 'setSign', title: '借款方', width: 120, sort: 'true'}
                            , {field: 'BYNAME', event: 'setSign', title: '别名', width: 120, sort: 'true'}
                            , {field: 'PAY_PRICE', event: 'setSign', title: '支付金额', width: 120,align: 'right', sort: 'true'}
                            , {field: 'START_DATE', event: 'setSign', title: '账单周期', width: 200, sort: 'true'}
                            , {field: 'BILL_NAME', event: 'setSign', title: '账单类型', width: 120, sort: 'true'}
                            , {field: 'COLLECTION_TYPE', event: 'setSign', title: '收款账户', width: 120, sort: 'true'}
                            , {field: 'ACT_PAY_DATE', event: 'setSign', title: '实收日期', width: 120, sort: 'true'}
                            , {field: 'PAY_METHOD', event: 'setSign', title: '支付方式', width: 140, sort: 'true'}
                            , {field: 'PAY_TRANSACTION', event: 'setSign', title: '流水号', width: 140, sort: 'true'}
                            , {field: 'INFO', event: 'setSign', title: '备注', width: 120, sort: 'true'}
                            , {fixed: 'right',  event: 'setSign',align: 'center', title: '操作', toolbar: '#lsmxbar', width: 160}

                        ]]
                        , id: 'shouruID'
                        , page: true
                        , height: '470'
                        , limit: '10'
                        , done: function(res, curr, count){
                            var total=0;
                            for(var i=0;i<res.data.length;i++){
                                console.log(res.data[i].PAY_PRICE)
                                total+=parseFloat(res.data[i].PAY_PRICE);
                            }
                            $(".total_price").remove();
                            $(".layui-table-page").append('<span class="total_price" style="height: 10px;margin:10px 10px 0px 30px"><span>账单金额汇总：' + total.toFixed(2)+'元</span></span>');
                        }
                    });
                    break;
            }
        });
        //加载应收列表
        table.render({
            elem: '#szlb'
            , url: '/LoanController/yingshouList'
            , where: data
            , cols: [[
                {checkbox: true, LAY_CHECKED: true} //默认全选
                , {field: 'COMPANY_NAME', event: 'setSign', title: '借款方', width: 120, sort: 'true'}
                , {field: 'BYNAME', event: 'setSign', title: '别名', width: 120, sort: 'true'}
                , {field: 'TOTAL_PRICE', event: 'setSign', title: '账单金额',align:'right', width: 120, sort: 'true'}
                , {field: 'SIGNER_TEL', event: 'setSign', title: '联系方式', width: 120, sort: 'true'}
                , {field: 'START_DATE', event: 'setSign', title: '账单周期', width: 200, sort: 'true'}
                , {field: 'BILL_NAME', event: 'setSign', title: '账单类型', width: 120, sort: 'true'}
                /* , {field: 'STATE', event: 'setSign', title: '账单状态', width: 120}*/
                , {field: 'PAY_DATE', event: 'setSign', title: '应收费日', width: 120, sort: 'true'}
                , {field: 'ALLOT_BILL', event: 'setSign', title: '收费类型', align: 'center', width: 120, sort: 'true'}
                , {field: 'MAKE_BILL_TYPE', event: 'setSign', title: '生成类型', align: 'center', width: 120}
                , {field: 'STATE', event: 'setSign', title: '账单状态', align: 'center', width: 120, sort: 'true'}
                , {field: 'INFO', event: 'setSign', title: '备注', width: 120}
                , {fixed: 'right', width: 200, align: 'center', title: '操作', toolbar: '#dclbar'}

            ]]

            , id: 'szlbID'
            , page: true
            , width: 'full'
            , height:"470"
            , maxHeight:600
            , limit: '10'
            , footer:true
            , done: function(res, curr, count){
                var total=0;
                for(var i=0;i<res.data.length;i++){
                    total+=parseFloat(res.data[i].TOTAL_PRICE);
                }
                $(".total_price").remove();
                // $(".layui-table-body").append('<div class="layui-table-foot" style="overflow: hidden;"><table cellspacing="0" cellpadding="0" border="0" class="layui-table"><tfoot><tr id="totalData" class="tr_sum"><td><div class="layui-table-cell laytable-cell-10003-item1"><span>账单汇总：</span></div></td><td><div class="layui-table-cell laytable-cell-10003-BUILDING_NAME"><span>' + total.toFixed(2)+'</span></div></td></tr></tfoot></table></div>');
                $(".layui-table-page").append('<span class="total_price" style="height: 10px;margin:10px 10px 0px 30px"><span>账单金额汇总：' + total.toFixed(2)+'元</span></span>');

            }
        });



        //待处理账单   查看 监听工具条 查看查看查看
        table.on('tool(szlbf)', function (obj) {
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            var nametype = data.BILL_NAME;
            var COMPANY_NAME = data.COMPANY_NAME;
            var BYNAME = data.BYNAME;
            console.log(data)
            var type;
            var hideShoukuan = "1";
            //有滞纳金标识
            var LATE_FEE = data.LATE_FEE;
            var isLATE = "";
            if ("-" == LATE_FEE) {
                isLATE = 0;
            } else {
                isLATE = LATE_FEE;
            }
            if (layEvent === 'detail') {
                parent.layer.open({
                    zIndex: 1000,
                    type: 2,    //弹出类型
                    title: '查看账单',   //标题
                    closeBtn: 1,    //显示关闭按钮
                    shade: [0.3],   //遮罩透明度
                    area: ['80%', '90%'],  //打开窗口的宽高
                    time: 0,    //几秒后自动关闭，默认0时不关闭
                    anim: 1,    //动画效果
                    resize: false,  //设置成不允许拉伸
                    content: '../../../webhtml/contract/bill_check.html?hd=' + escape(hideShoukuan) + '&type=' + escape(nametype) + '&BILL_ID=' + data.ID + ''  //iframe的url
                });
            } else if (layEvent === 'dclsf') {
                parent.layer.open({
                    zIndex: 1000,
                    type: 2,    //弹出类型
                    title: '收费',   //标题
                    closeBtn: 1,    //显示关闭按钮
                    shade: [0.3],   //遮罩透明度
                    area: ['80%', '90%'],  //打开窗口的宽高
                    time: 0,    //几秒后自动关闭，默认0时不关闭
                    anim: 1,    //动画效果
                    resize: false,  //设置成不允许拉伸
                    content: '../../../webhtml/contract/loan_charge.html?isLATE=' + isLATE + '&COMPANY_NAME=' + escape(COMPANY_NAME) + '&BYNAME=' + escape(BYNAME) + '&BILL_ID=' + data.ID + ''  //iframe的url
                });
                $(this).blur(); //移除焦点，防止点击回车按钮造成多次打开
            }
            else if (layEvent === 'editbill') {
                //判断 是0租金  1  物业费2 等 传给修改页面 是否显示 物业 或者 租金
                var nametype = data.BILL_NAME;
                var type;
                parent.layer.open({
                    zIndex: 1000,
                    type: 2,    //弹出类型
                    title: '修改账单',   //标题
                    closeBtn: 1,    //显示关闭按钮
                    shade: [0.3],   //遮罩透明度
                    area: ['80%', '90%'],  //打开窗口的宽高
                    time: 0,    //几秒后自动关闭，默认0时不关闭
                    anim: 1,    //动画效果
                    resize: false,  //设置成不允许拉伸
                    content: '../../../webhtml/contract/bill_check.html?&type=' + escape(nametype) + '&button=edit&BILL_ID=' + data.ID + '' //iframe的url
                });
                $(this).blur(); //移除焦点，防止点击回车按钮造成多次打开
            }
            else if (layEvent === 'print') {
                print(data.ID);
            }
        });
        //已处理 已收 账单   查看
        table.on('tool(yichulif)', function (obj) {
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            var nametype = data.BILL_NAME;
            var type;
            var jymx = "1";//为了显示 已收账单的交易明细
            if (layEvent === 'detail') {
                if("停车费"==data.BILL_NAME){
                    parent.layer.open({
                        zIndex: 1000,
                        type: 2,    //弹出类型
                        title: '查看账单',   //标题
                        closeBtn: 1,    //显示关闭按钮
                        shade: [0.3],   //遮罩透明度
                        area: ['80%', '90%'],  //打开窗口的宽高
                        time: 0,    //几秒后自动关闭，默认0时不关闭
                        anim: 1,    //动画效果
                        resize: false,  //设置成不允许拉伸
                        content: '../../../webhtml/contract/Parking_charges.html?&jymx=' + escape(jymx) + '&&type=' + escape(nametype) + '&button=1&BILL_ID=' + data.ID + ''  //iframe的url
                    });
                }else {
                    parent.layer.open({
                        zIndex: 1000,
                        type: 2,    //弹出类型
                        title: '查看账单',   //标题
                        closeBtn: 1,    //显示关闭按钮
                        shade: [0.3],   //遮罩透明度
                        area: ['80%', '90%'],  //打开窗口的宽高
                        time: 0,    //几秒后自动关闭，默认0时不关闭
                        anim: 1,    //动画效果
                        resize: false,  //设置成不允许拉伸
                        content: '../../../webhtml/contract/bill_check.html?&jymx=' + escape(jymx) + '&&type=' + escape(nametype) + '&button=1&BILL_ID=' + data.ID + ''  //iframe的url
                    });
                }

            } else if (layEvent === 'yclbar') {

            }
        });
        //应付  账单   查看


        //查询 已收账单
        $('.operateTableys .ys').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATE").val();
            data.END_DATE = $("#END_DATE").val();
            data.COMPANY_NAME = $("#COMPANY_NAME").val();
            data.BILL_NAME = $("#BILL_NAME").val();
            data.BYNAME = $("#BYNAME").val();
            data.TOTAL_PRICE = $("#TOTAL_PRICE").val();
            data.TOTAL_PRICE_STA = $("#TOTAL_PRICE_STA").val();
            data.TOTAL_PRICE_END = $("#TOTAL_PRICE_END").val();
            table.reload('yclID', {
                where: data
            });
        });
        //查询 应付账单
        $('.operateTableyf .yf').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATEyf").val();
            data.END_DATE = $("#END_DATEyf").val();
            data.COMPANY_NAME = $("#COMPANY_NAMEyf").val();
            data.BILL_NAME = $("#BILL_NAMEyf").val();
            data.BYNAME = $("#BYNAMEyf").val();
            data.TOTAL_PRICE = $("#TOTAL_PRICEyf").val();
            data.TOTAL_PRICE_STA = $("#TOTAL_PRICEyfSTA").val();
            data.TOTAL_PRICE_END = $("#TOTAL_PRICEyfEND").val();
            table.reload('yingfuID', {
                where: data
            });
        });
        //查询 未收账单
        $('.operateTablews .ws').on('click', function () {
            var data = {};
            data.paystar = $("#START_DATEw").val();
            data.payend = $("#END_DATEw").val();
            data.COMPANY_NAME = $("#COMPANY_NAMEw").val();
            data.BILL_NAME = $("#BILL_NAMEw").val();
            data.BYNAME = $("#BYNAMEw").val();
            data.TOTAL_PRICE = $("#TOTAL_PRICEw").val();
            data.TOTAL_PRICE_STA = $("#TOTAL_PRICEwSTA").val();
            data.TOTAL_PRICE_END = $("#TOTAL_PRICEwEND").val();
            data.ALL_DATA = $("#ALL_DATA").val();
            table.reload('szlbID', {
                where: data
            });
        });
        //查询 逾期账单
        $('.operateTableyq .yq').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATEy").val();
            data.END_DATE = $("#END_DATEy").val();
            data.COMPANY_NAME = $("#COMPANY_NAMEy").val();
            data.BILL_NAME = $("#BILL_NAMEy").val();
            data.BYNAME = $("#BYNAMEy").val();
            data.TOTAL_PRICE = $("#TOTAL_PRICEy").val();
            data.TOTAL_PRICE_STA = $("#TOTAL_PRICEySTA").val();
            data.TOTAL_PRICE_END = $("#TOTAL_PRICEyEND").val();
            table.reload('yqlbID', {
                where: data
            });
        });
        //查询 自用账单
        $('.operateTablezy .zy').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATEziy").val();
            data.END_DATE = $("#END_DATEziy").val();
            data.TOTAL_PRICE = $("#TOTAL_PRICEzy").val();
            data.TOTAL_PRICE_STA = $("#TOTAL_PRICEzySTA").val();
            data.TOTAL_PRICE_END = $("#TOTAL_PRICEzyEND").val();
            data.BILL_NAME = $("#BILL_NAMEzy").val()
            table.reload('ZIYONG', {
                where: data
            });
        });
        //查询 流水 收入
        $('.operateTablesy .layui-btn').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATEsy").val();
            data.END_DATE = $("#END_DATEsy").val();
            data.COMPANY_NAME = $("#COMPANY_NAMEsy").val();
            data.BILL_NAME = $("#BILL_NAMEsy").val()
            data.BYNAME = $("#BYNAMEsy").val();
            table.reload('shouruID', {
                where: data
            });
        });
        //查询 流水 支出
        $('.operateTablezc .layui-btn').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATEzc").val();
            data.END_DATE = $("#END_DATEzc").val();
            data.COMPANY_NAME = $("#COMPANY_NAMEzc").val();
            data.BILL_NAME = $("#BILL_NAMEzc").val()
            data.BYNAME = $("#BYNAMEzc").val();
            table.reload('zhichuID', {
                where: data
            });
        });
        //查询 审批账单
        $('.operateTablespzd .spzd').on('click', function () {
            var data = {};
            data.START_DATE = $("#START_DATEspzd").val();
            data.END_DATE = $("#END_DATEspzd").val();
            data.COMPANY_NAME = $("#COMPANY_NAMEspzd").val();
            data.BILL_NAME = $("#BILL_NAMEspzd").val()
            data.BYNAME = $("#BYNAMEspzd").val();
            table.reload('shenpiID', {
                where: data
            });
        });




        //支出 查看
        table.on('tool(zcf)', function (obj) {
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            var nametype = data.BILL_NAME;
            if (layEvent === 'detail') {
                parent.layer.open({
                    zIndex: 1000,
                    type: 2,    //弹出类型
                    title: '查看账单',   //标题
                    closeBtn: 1,    //显示关闭按钮
                    shade: [0.3],   //遮罩透明度
                    area: ['80%', '90%'],  //打开窗口的宽高
                    time: 0,    //几秒后自动关闭，默认0时不关闭
                    anim: 1,    //动画效果
                    resize: false,  //设置成不允许拉伸
                    content: '../../../webhtml/contract/bill_check.html?type=' + escape(nametype) + '&BILL_ID=' + data.ID + ''  //iframe的url
                });
            } else if (layEvent === '') {

            }
        });

        //切换金额搜索 区间 和 等值金额
        $(".qiehuanjine").click(function () {

        });
        //监听 切换金额搜索 区间 和 等值金额
        $('.qiehuanw').change(function () {
            if ("0" == $(this).children('option:selected').val()) {
                //固定金额
                $(".qiehuanjinew").html("<div class=\"layui-inline\">\n" +
                    "                                <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICEw\" placeholder=\"金额\" >\n" +
                    "                            </div>");
            }
            if ("1" == $(this).children('option:selected').val()) {
                $(".qiehuanjinew").html("<div class=\"layui-inline jinebox\">\n" +
                    "                                    <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICEwSTA\" placeholder=\"最小值\" >\n" +
                    "                                </div>\n" +
                    "                                <div class=\"layui-inline jinebox\">\n" +
                    "                                    <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICEwEND\" placeholder=\"最大值\" >\n" +
                    "                                </div>");
            }
        });
        $('.qiehuan').change(function () {
            if ("0" == $(this).children('option:selected').val()) {
                //固定金额
                $(".qiehuanjine").html("<div class=\"layui-inline\">\n" +
                    "                                <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICE\" placeholder=\"金额\" >\n" +
                    "                            </div>");
            }
            if ("1" == $(this).children('option:selected').val()) {
                $(".qiehuanjine").html("<div class=\"layui-inline jinebox\">\n" +
                    "                                    <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICE_STA\" placeholder=\"最小值\" >\n" +
                    "                                </div>\n" +
                    "                                <div class=\"layui-inline jinebox\">\n" +
                    "                                    <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICE_END\" placeholder=\"最大值\" >\n" +
                    "                                </div>");
            }
        })
        $('.qiehuany').change(function () {
            if ("0" == $(this).children('option:selected').val()) {
                //固定金额
                $(".qiehuanjiney").html("<div class=\"layui-inline\">\n" +
                    "                                <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICEy\" placeholder=\"金额\" >\n" +
                    "                            </div>");
            }
            if ("1" == $(this).children('option:selected').val()) {
                $(".qiehuanjiney").html("<div class=\"layui-inline jinebox\">\n" +
                    "                                    <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICEySTA\" placeholder=\"最小值\" >\n" +
                    "                                </div>\n" +
                    "                                <div class=\"layui-inline jinebox\">\n" +
                    "                                    <input class=\"layui-input\" name=\"TOTAL_PRICE\" id=\"TOTAL_PRICEyEND\" placeholder=\"最大值\" >\n" +
                    "                                </div>");
            }
        })
        $(".plsf").click(function () {
            var data = table.checkStatus('szlbID').data;
            var pd = initDatas(data);
            var data = {};
            data.BILL_ID = pd;
            layer.msg('确定批量收费？', {
                time: 20000, //20s后自动关闭
                btn: ['确定', '取消',]
                , yes: function (index) {
                    layer.close(index); // 关闭当前提示框
                    $.ajax({
                        url: "/billController/savebillpayALL",
                        data: data,
                        dataType: "json",
                        type: "post",
                        async: false,
                        success: function (res) {
                            if (res.errcode === "0") {
                                var i = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(i);  // 关闭修改房间页面
                                parent.layer.msg("批量收款成功", {offset: '150px'});   // 父页面弹出修改成功

                            } else if (res.errcode === "1") {
                                layer.msg(res.errmsg, function () {
                                });
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            console.error(XMLHttpRequest.status);
                            console.error(XMLHttpRequest.readyState);
                            console.error(textStatus);
                        }
                    });
                    reloadszTbale();
                }
            });
        });
        //打印凭证-应收
        $(".plsf-ys").click(function () {
            var data = table.checkStatus('szlbID').data;
            var pd = initDatas(data);
            print(pd);
        });
        //打印凭证-逾期
        $(".plsf-yq").click(function () {
            var data = table.checkStatus('yqlbID').data;
            var pd = initDatas(data);
            print(pd);
        });

        // 打印凭证
        function print(ids) {
            if (!ids) {
                layer.alert("至少选择一个账单");
                return false;
            } else {
                ids = ids.replace(/(.*)[,，]$/, '$1');
                layer.open({
                    type: 2,
                    title: '打印凭证',
                    shadeClose: false,
                    shade: [0.3],
                    maxmin: true, //开启最大化最小化按钮
                    area: ['100%', '100%'],
                    scrollbar: false, //屏蔽滚动条
                    content: './../contract/contract_print.html?type=1&id=' + ids
                });
            }
        }

        //批量生成账单封装数据id
        function initDatas(data) {
            var rs;
            $.each(data, function (i, info) {
                if (i == 0) {
                    rs = info.ID + ",";
                } else {
                    rs += "" + info.ID + ",";
                }

            })
            return rs;
        }
        //加载 统计信息 收入支出 和 收入支出差
        $.ajax({
            url: "/property/propertyListALL/",
            dataType: "json",
            type: "post",
            async: false,
            success: function (res) {
                if (res.errcode === "0") {
                } else if (res.errcode === "1") {
                    layer.msg(res.errmsg, function () {
                    });
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.error(XMLHttpRequest.status);
                console.error(XMLHttpRequest.readyState);
                console.error(textStatus);
            }
        });
    });

    //提交收款后 刷新table
    function reloadszTbale() {
        table.reload("szlbID", {});
    }

    function reloadsylbTbale() {
        table.reload("shouruID", {});
    }
    //收入预算
    function reloadsyysTbale() {
        table.reload("shouruyusuanID", {});
    }

    // 导出excel 应收
    function excel() {
        var data = {};
        data.START_DATE = $("#START_DATEw").val();
        data.END_DATE = $("#END_DATEw").val();
        data.COMPANY_NAME = $("#COMPANY_NAMEw").val();
        data.BILL_NAME = $("#BILL_NAMEw").val();
        data.BYNAME = $("#BYNAMEw").val();
        data.TOTAL_PRICE = $("#TOTAL_PRICEw").val();
        data.TOTAL_PRICE_STA = $("#TOTAL_PRICEwSTA").val();
        data.TOTAL_PRICE_END = $("#TOTAL_PRICEwEND").val();
        data.BUILDING_ID = BUILDING_ID;
        data.BUSINESS_ID = BUSINESS_ID;
        data.ALL_DATA = $("#ALL_DATA").val();
        data = JSON.stringify(data);
        data=data.replace("{","[");
        data=data.replace("}","]");
        window.open("/billController/excel?DATA=" + data);

    }
    // 导出excel 已收
    function excel_yichuli() {
        var data = {};
        data.START_DATE = $("#START_DATE").val();
        data.END_DATE = $("#END_DATE").val();
        data.COMPANY_NAME = $("#COMPANY_NAME").val();
        data.BILL_NAME = $("#BILL_NAME").val();
        data.BYNAME = $("#BYNAME").val();
        data.TOTAL_PRICE = $("#TOTAL_PRICE").val();
        data.TOTAL_PRICE_STA = $("#TOTAL_PRICE_STA").val();
        data.TOTAL_PRICE_END = $("#TOTAL_PRICE_END").val();
        data.BUILDING_ID = BUILDING_ID;
        data.BUSINESS_ID = BUSINESS_ID;
        data = JSON.stringify(data);
        data=data.replace("{","[");
        data=data.replace("}","]");
        window.open("/billController/excel_yichuli?DATA=" + data);
    }



</script>
</body>
</html>
